package de.schiess.main;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

import javax.smartcardio.Card;



public class Reader {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws FileNotFoundException 
	 * @throws ClassNotFoundException 
	 */
	public static  HashMap<Date, ArrayList<Card>> getFile(String fileName) throws FileNotFoundException, IOException, ClassNotFoundException {
		File file = new File(fileName); ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); 
		HashMap<Date, ArrayList<Card>> map = (HashMap<Date, ArrayList<Card>>) in.readObject(); 
		in.close(); 
		return map;

	}
	public static ArrayList<Card> getFileAsList(String fileName) throws FileNotFoundException, IOException, ClassNotFoundException{
		File file = new File(fileName); ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); 
		HashMap<Date, ArrayList<Card>> map = (HashMap<Date, ArrayList<Card>>) in.readObject(); 
		in.close(); 
		ArrayList<Card> list = new ArrayList<Card>();
		for(Date date : map.keySet()){
			list.addAll(map.get(date));
		}
		return list;
	}
	

}
